package server.net.protocol.ping;

import java.util.logging.Level;
import java.util.logging.Logger;
import server.net.Client;

/**
 * This object represents the task executed when a pong is not received 
 * in time to a challenge ping.
 * 
 * For now, we just disconnect the client.
 *
 * @author Vincent Tsuei
 * @version 2012-11-16
 */
public class DisconnectTask implements Runnable {
    
    private final Client client;
    
    public DisconnectTask(Client client) {
        this.client = client;
    }

    @Override
    public void run() {
        Logger.getLogger(DisconnectTask.class.getName()).log(Level.INFO, "[Ping] Client {0} did not respond in time. Disconnecting ...", 
                new Object[]{client.getConnection().getAddressAndPortString()} );
        client.disconnect();
    }
    
}
